#include "Object.h"

//  默认实现
static void Object_Destroy_Default(Object* self){
    free(self);
}

static const char* Object_ToString_Default(Object* self){
    return "Object";
}

static const char* Object_GetType_Default(Object* self){
    return "Object";
}


static ObjectVTable Object_VTable = {
    Object_Destroy_Default,
    Object_ToString_Default,
    Object_GetType_Default
};

static Object* Object_Create_Default(void){
    Object* self = (Object*)malloc(sizeof(Object));
    if(!self)
        return NULL;
    self->vtbl = &Object_VTable;
    return self;
}

//  封装接口调用
void Object_Destroy(Object* self){
    self->vtbl->Destroy(self);
}

const char* Object_ToString(Object* self){
    self->vtbl->ToString(self);
}

const char* Object_GetType(Object* self){
    return self->vtbl->GetType(self);
}
